import { Column, Entity, PrimaryGeneratedColumn, BeforeUpdate, BeforeInsert } from 'typeorm'
import moment from 'moment'

// 扩延伸项目清单
@Entity()
export class DateEntity {
  @Column({
    name: 'create_time',
    type: 'text',
    comment: '创建时间',
    options: {
      camelCaseColumns: true
    }
  } as any)
  createTime: string

  // 创建时间
  @Column({
    name: 'update_time',
    type: 'text',
    comment: '创建时间',
    nullable: true
  })
  updateTime: string

  @BeforeInsert()
  createDate() {
    this.createTime = moment().format('YYYY-MM-DD HH:mm:ss')
  }

  @BeforeUpdate()
  updateDate() {
    this.updateTime = moment().format('YYYY-MM-DD HH:mm:ss')
  }
}
